package com.feilo.action;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.feilo.biz.UserBiz;
import com.feilo.biz.impl.UserBizImpl;
import com.feilo.entity.Log;
import com.feilo.entity.User;
import com.feilo.util.ProReader;
import com.opensymphony.xwork2.ActionContext;
import com.zoo.pojo.Page;
@Controller
@Scope("prototype")
public class UserAction {
	private String msg;
	@Resource
	UserBiz us=new UserBizImpl();
	User user;
	String ip=ServletActionContext.getRequest().getRemoteAddr();
	String addName=(String) ActionContext.getContext().getSession().get("user");
	//��ҳ��Ϣ������ȡ��pageInfo
    private int pageNo = 1; 
    private Page pageInfo;
	private String url ;
	private String skipUrl;
	private String text;
	List<User> users;
	int starts,ends,record,page;
	
	/**
	 * ��ת���û��б�
	 */
	public String userList(){
		List<User> list = us.getUsers();
		int pageSize = Integer.parseInt(ProReader.getInstance().getProperty("pageSize"));
		int showCount = Integer.parseInt(ProReader.getInstance().getProperty("showCount"));
        pageInfo = new Page(pageNo, pageSize, users.size(),showCount);   
        list = users.subList(pageInfo.getRecordStart() - 1, pageInfo.getRecordEnd());  
        url="user_userList.do";   
		return "userList";
	}
	
	/**
	 * �����û��б�
	 */
	public String search(){
		List<User> list = us.getUsersBySerch(user.getU_username()); 
		int pageSize = Integer.parseInt(ProReader.getInstance().getProperty("pageSize"));
		int showCount = Integer.parseInt(ProReader.getInstance().getProperty("showCount"));
        Page pageInfo = new Page(pageNo, pageSize, users.size(),showCount);   
        list = users.subList(pageInfo.getRecordStart() - 1, pageInfo.getRecordEnd()); 
        url="user_search.do";   
		return "userList";
	}
	/**
	 * ɾ���û�
	 * @return
	 */
	/**
	 * �û���ϸ��Ϣ
	 * @return
	 */
	/**
	 * 删除用户
	 * @return
	 */
	public String delete(){
	return "delete";
	}
	/**
	 * 用户详细信息
	 * @return
	 */
	public String view(){
		this.user=us.getUser(user.getId());
		return "view";
	}
	/**
	 * 用户详细信息
	 * @return
	 */
	public String editUI(){
		this.user=us.getUser(user.getId());
		return "editUI";
	}
	/**
	 * 编辑用户
	 */
	public String edit(){
		
			return "message";
	}
	/**
	 * �༭�û�
	 */
	/*getter ��setter����*/
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public List<User> getUsers() {
		return users;
	}
	public void setUsers(List<User> users) {
		this.users = users;
	}
	public String getSkipUrl() {
		return skipUrl;
	}

	public void setSkipUrl(String skipUrl) {
		this.skipUrl = skipUrl;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}
	public UserBiz getUs() {
		return us;
	}

	public void setUs(UserBiz us) {
		this.us = us;
	}

	public Page getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(Page pageInfo) {
		this.pageInfo = pageInfo;
	}

	public int getStarts() {
		return starts;
	}

	public void setStarts(int starts) {
		this.starts = starts;
	}

	public int getEnds() {
		return ends;
	}

	public void setEnds(int ends) {
		this.ends = ends;
	}

	public int getRecord() {
		return record;
	}

	public void setRecord(int record) {
		this.record = record;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

}
